<#include "/custom.include">
<#include "/java_copyright.include">
<#assign className = table.className>   
<#assign classNameLower = className?uncap_first>
<#assign actionExtension = "do">
package ${basepackage}.controller.${namespace};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import ${basepackage}.biz.${namespace}.service.${className}Service;
import ${basepackage}.pojo.DataGrid;
import ${basepackage}.pojo.Result;
import ${basepackage}.client.domain.${namespace}.${className};
import ${basepackage}.client.query.${namespace}.${className}Query;

@Controller
@RequestMapping(value="/${namespace}/${classNameLower}") 
public class ${className}Controller{
	
	@Autowired
	private ${className}Service ${classNameLower}Service;
	
	private Result result = new Result();
	/**
	 * 跳转到${table.tableAlias}管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value="go${className}")
	public String go${className}() {
		return "${namespace}/${classNameLower}";
	}
	/**
	 * 跳转到${table.tableAlias}新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value="handle${className}")
	public String handle${className}(@RequestParam(value="id",required=false) Long id ,ModelMap map) {
		return "${namespace}/${classNameLower}_rowEdit";
	}

	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="showDesc")
	public ${className} showDesc(${className}Query ${classNameLower}Query) {
		return ${classNameLower}Service.get(${classNameLower}Query);
	}

	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(${className}Query ${classNameLower}Query) {
		return ${classNameLower}Service.datagrid(${classNameLower}Query);
	}
	

	/**
	 * 添加一个${table.tableAlias}
	 */
	@ResponseBody
	@RequestMapping(value="add")
	public Result add(${className}Query ${classNameLower}Query) {
		${classNameLower}Service.add(${classNameLower}Query);
		result.setSuccess(true);
		result.setMsg("添加成功！");
		return result;
	}

	/**
	 * 编辑${table.tableAlias}
	 */
	@ResponseBody
	@RequestMapping(value="edit")
	public Result edit(${className}Query ${classNameLower}Query) {
		${classNameLower}Service.update(${classNameLower}Query);
		result.setSuccess(true);
		result.setMsg("编辑成功！");
		return result;
	}

	/**
	 * 物理删除${table.tableAlias}
	 */
	@ResponseBody
	@RequestMapping(value="delete")
	public Result delete(${className}Query ${classNameLower}Query) {
		${classNameLower}Service.delete(${classNameLower}Query.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	
	/**
	 * 逻辑删除${table.tableAlias}
	 */
	@ResponseBody
	@RequestMapping(value="deletePt")
	public Result deletePt(${className}Query ${classNameLower}Query) {
		${classNameLower}Service.deletePt(${classNameLower}Query.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
}
